package com.mb.mp.vo;

import java.util.LinkedHashMap;
import java.util.Map;

/**
 * @author zhanxuewei
 * @Title: ${file_name}
 * @Package ${package_name}
 * @Description: ${todo}
 * @date 2018/4/1810:46
 */
public class QueryVO extends LinkedHashMap<String, Object> {

    private static final long serialVersionUID = 1L;
    //
    private int offset;
    // 每页条数
    private int limit;

    private Long provinceId;
    private Long cityId;
    private Long villageId;

//    private String uxiliaryName;
//    private Long uxiliaryId;

//    private Object type;

    public QueryVO(Map<String, Object> params) {
        this.putAll(params);
        // 分页参数
        this.offset = Integer.parseInt(params.get("offset").toString());
        this.limit = Integer.parseInt(params.get("limit").toString());
//        this.uxiliaryName = params.get("uxiliaryName").toString();
//        this.uxiliaryId = Long.parseLong(params.get("uxiliaryId").toString());
//        this.type = params.get("uxiliaryId");
        Object provinceId = params.get("provinceId");
        Object cityId = params.get("cityId");
        Object villageId = params.get("villageId");
        if (provinceId == null || provinceId == "") {
            this.provinceId = null;
        } else {
            this.provinceId = Long.parseLong(provinceId.toString());
        }
        if (cityId == null || cityId == "") {
            this.cityId = null;
        } else {
            this.cityId = Long.parseLong(cityId.toString());
        }
        if (villageId == null || villageId == "") {
            this.villageId = null;
        } else {
            this.villageId = Long.parseLong(villageId.toString());
        }
        this.put("offset", offset);
        this.put("page", offset / limit + 1);
        this.put("limit", limit);
//        this.put("uxiliaryName", uxiliaryName);
//        this.put("uxiliaryId", uxiliaryId);
//        this.put("type", type);
        this.put("provinceId", this.provinceId);
        this.put("cityId", this.cityId);
        this.put("villageId", this.villageId);
    }

//    public Object getType() {
//        return type;
//    }

//    public void setType(Object type) {
//        this.type = type;
//    }

    public int getOffset() {
        return offset;
    }

    public void setOffset(int offset) {
        this.offset = offset;
    }

    public int getLimit() {
        return limit;
    }

    public void setLimit(int limit) {
        this.limit = limit;
    }

//    public String getUxiliaryName() {
//        return uxiliaryName;
//    }
//
//    public void setUxiliaryName(String uxiliaryName) {
//        this.uxiliaryName = uxiliaryName;
//    }


    public Long getProvinceId() {
        return provinceId;
    }

    public void setProvinceId(Long provinceId) {
        this.provinceId = provinceId;
    }

    public Long getCityId() {
        return cityId;
    }

    public void setCityId(Long cityId) {
        this.cityId = cityId;
    }

    public Long getVillageId() {
        return villageId;
    }

    public void setVillageId(Long villageId) {
        this.villageId = villageId;
    }
}
